package app.ep1.test;

import java.util.ArrayList;
import java.util.List;

import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;
import app.ep1.bandejoes.InformacoesBandejaoActivity;
import app.ep1.bandejoes.OpiniaoBandejao;
import app.ep1.bandejoes.TamanhoFila;
import app.ep1.R;

public class InformacoesBandejaoValidation extends
		ActivityInstrumentationTestCase2<InformacoesBandejaoActivity> {
	public InformacoesBandejaoValidation() {
		super("app.ep1.bandejoes", InformacoesBandejaoActivity.class);
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	public void testCarregaOpiniaoNaTela() throws Throwable {
		final InformacoesBandejaoActivity informacoesBandejaoActivity = getActivity();

		String textoOpiniao = "teste";

		OpiniaoBandejao opiniao = new OpiniaoBandejao();
		opiniao.setData();
		opiniao.setFila(TamanhoFila.MEDIA);
		opiniao.setTexto(textoOpiniao);

		List<OpiniaoBandejao> opinioes = new ArrayList<OpiniaoBandejao>();
		opinioes.add(opiniao);

		informacoesBandejaoActivity.setListaDeOpinioes(opinioes);

		runTestOnUiThread(new Runnable() {
			@Override
			public void run() {
				informacoesBandejaoActivity.carregaComentarioNaTela(0);
			}
		});

		TextView textView = (TextView) informacoesBandejaoActivity
				.findViewById(R.id.textViewComentarioBandejao);

		assertEquals(textoOpiniao, textView.getText().toString());
	}
}
